<template>
  <div>
    <div>
      <mt-header title="修改性别" style="background: linear-gradient(#000000, #035838);">
        <mt-button icon="back" slot="left" @click="goBack()">返回</mt-button>
      </mt-header>
    </div>
    <div id="choosegender">
      <mt-radio :max="1" v-model="value" :options="options">
      </mt-radio>
    </div>
    <div class="promoters-button">
      <button class="mint-button mint-button--default mint-button--large is-plain" @click="updateSex()">
        <label class="mint-button-text">保存</label>
      </button>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import { Indicator } from "mint-ui";
import { Toast } from "mint-ui";
export default {
  name: "choosegender",
  data() {
    return {
      value: this.$route.query.rq,
      // checklist设置
      options: [
        {
          label: "男",
          value: "男",
          disabled: false
        },
        {
          label: "女",
          value: "女",
          disabled: false
        },
        {
          label: "保密",
          value: "保密",
          disabled: false
        }
      ]
    };
  },
  methods: {
    goBack() {
      history.go(-1);
    },
    updateSex() {
      let sex = this.value[0];
      let global_members_id = JSON.parse(
        localStorage.getItem("global_members_id")
      );
      console.log(sex);
      axios({
        method: "post",
        url: "/api/updategrxx/grxxbj.htm",
        params: {
          id: global_members_id,
          sex: sex
        }
      }).then(res => {
        res = res.data;
        if (res.zt === "true") {
          history.go(-1);
        } else {
          Indicator.close();
          let instance = Toast({
            message: "更新失败"
          });
          setTimeout(() => {
            instance.close();
          }, 2000);
        }
      });
    }
  }
};
</script>
<style scoped>
.promoters-button {
  height: 150px;
  width: 80%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: auto;
}
</style>